package lu.uni.adtool.domains.predefined;

import lu.uni.adtool.domains.Domain;

import lu.uni.adtool.domains.rings.RealZeroOne;

/**
 * A Domain defined on booleans.
 * 
 * @author Piot Kordy
 */
public class ProbPlusTimes implements Domain<RealZeroOne>
{
  //number 8
  static final long serialVersionUID = 865945232556446848L;
  /**
   * Constructs a new instance.
   */
  public ProbPlusTimes()
  {
  }

  /**
   * {@inheritDoc}
   * @see Domain#getDefaultValue()
   */
  public final RealZeroOne getDefaultValue(final boolean proponent)
  {
    if  (proponent){
      return new RealZeroOne(0);
    }
    else{
      return new RealZeroOne(0);
    }
  }
  /**
   * {@inheritDoc}
   * @see Domain#isValueModifiable(boolean)
   */
  public final boolean isValueModifiable(final boolean proponent)
  {
    return true;
  }
  /**
   * {@inheritDoc}
   * @see Domain#getName()
   */
  public final String getName()
  {
    return "Probability of success";
  }
  /**
   * {@inheritDoc}
   * @see Domain#getDescription()
   */
  public final String getDescription()
  {
    final String name = "Probability of success, assuming "
      + "that all actions are mutually independent";
    final String vd = "[0,1]";
    final String[] operators = {"<i>x</i>&nbsp;+&nbsp;<i>y</i>&nbsp;-&nbsp;<i>x</i><i>y</i>",
                              "<i>x</i><i>y</i>",
                              "<i>x</i>&nbsp;+&nbsp;<i>y</i>&nbsp;-&nbsp;<i>x</i><i>y</i>",
                              "<i>x</i><i>y</i>",
                              "<i>x</i>(1&nbsp;-&nbsp;<i>y</i>)",
                              "<i>x</i>(1&nbsp;-&nbsp;<i>y</i>)"};
    return DescriptionGenerator.generateDescription(this, name, vd, operators);
  }

  /**
   * {@inheritDoc}
   * @see Domain#op(RealZeroOne,RealZeroOne)
   */
  public final RealZeroOne op(final RealZeroOne a, final RealZeroOne b)
  {
    return RealZeroOne.plusProb(a,b);
  }

  /**
   * {@inheritDoc}
   * @see Domain#ap(RealZeroOne,RealZeroOne)
   */
  public final RealZeroOne ap(final RealZeroOne a, final RealZeroOne b)
  {
    return RealZeroOne.times(a,b);
  }

  /**
   * {@inheritDoc}
   * @see Domain#oo(RealZeroOne,RealZeroOne)
   */
  public final RealZeroOne oo(final RealZeroOne a,final  RealZeroOne b)
  {
    return RealZeroOne.plusProb(a,b);
  }

  /**
   * {@inheritDoc}
   * @see Domain#ao(RealZeroOne,RealZeroOne)
   */
  public final RealZeroOne ao(final RealZeroOne a, final RealZeroOne b)
  {
    return RealZeroOne.times(a,b);
  }

  /**
   * {@inheritDoc}
   * @see Domain#cp(RealZeroOne,RealZeroOne)
   */
  public final RealZeroOne cp(final RealZeroOne a,final  RealZeroOne b)
  {
    return RealZeroOne.minusProb(a,b);
  }

  /**
   * {@inheritDoc}
   * @see Domain#co(RealZeroOne,RealZeroOne)
   */
  public final RealZeroOne co(final RealZeroOne a, final RealZeroOne b)
  {
    return RealZeroOne.minusProb(a,b);
  }
}



